﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GeneralAdaptiveFramework
{
    public class Connection
    {
        protected RequireInterface require;
        protected ProvideInterface provide;

        /**
         * Create a connection between two ports
         */
        public void create(ProvideInterface _provide, RequireInterface _require)
        {
#if DEBUG
            Console.WriteLine("Create a connection between: " + _provide.name + " and " + _require.name);
#endif
            require = _require;
            provide = _provide;
            //require.setCondition();
        }

        /**
         * Remove the connetion element
         */
        public void remove()
        {
            Console.WriteLine("Remove a connection between: " + provide.name + " and " + require.name);
            require = null;
            provide = null;
        }

        public String getRequireInterfaceInfo()
        {
            return require.name;
        }
        public String getProvideInterfaceInfo()
        {
            return provide.name;
        }
        
        /**
         * Transfer data
         */
        public void transfer(Object content)
        {
            require.receive(content);
        }
    }
}
